<template>
  <div class="app-container">
    <el-row class="head">
      <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        v-show="showSearch"
        label-width="6.s26rem"
      >
        <el-col :span="6">
          <el-form-item class="first-form" label="数据表名:" prop="tableName">
            <el-input
              v-model="queryParams.tableName"
              placeholder="请输入数据表名"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="5">
          <el-form-item label="状态:" prop="dataState">
            <el-select
              v-model="queryParams.dataState"
              size="small"
              placeholder="请选择"
            >
              <el-option key="0" label="物种" value="-1"> </el-option>
              <el-option key="1" label="动力" value="1"> </el-option>
              <el-option key="2" label="热力学" value="2"> </el-option>
              <el-option key="3" label="元数据" value="-2"> </el-option>
              <el-option key="4" label="热物性" value="0"> </el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="5">
          <el-form-item label="创建人:" prop="createrId">
            <el-input
              v-model="queryParams.createrId"
              placeholder="请输入创建人姓名"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col> -->
        <el-col :span="7">
          <el-form-item class="caoz">
            <el-button
              class="search-btn"
              type="danger"
              icon="el-icon-search"
              @click="handleQuery"
              >搜索</el-button
            >
            <el-button
              class="reset-btn"
              icon="el-icon-refresh-right"
              @click="resetQuery"
              >重置</el-button
            >
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <el-row class="card-list" v-loading="loading">
      <div class="card-title" style="font-size: 14px">待清洗数据表</div>
      <el-col :span="6" v-for="(item, index) in scckocMetaList" :key="index">
        <el-card shadow="never" class="data-card" :body-style="{ padding: 0 }">
          <div style="font-size: 18px; font-weight: bold">
            {{ item.tableName }}
          </div>
          <div class="card-img"></div>
          <div class="dn-card">
            {{ item.createTime }}
            {{ item.createBy == null ? "admin" : item.createBy }}
          </div>
          <div :class="'card-state' + (item.schemaId + 3)">
            {{ cardName[item.schemaId + 2] }}
          </div>
          <div class="caozuo">
            <el-link :underline="false" @click="handleDetail(item)"
              >{{ " " }}详情{{ " " }}</el-link
            >
            <el-link>|</el-link>
            <el-link
              class="lc"
              :underline="false"
              :type="item.dataState != 2 ? 'danger' : 'info'"
              :disabled="item.dataState == 2"
              @click="gethandleDelete(item)"
              >{{ "" }}删除{{ " " }}</el-link
            >
          </div>
        </el-card>
      </el-col>
    </el-row>
    <!-- 分页 -->
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      layout="prev, pager, next"
      @pagination="getList"
    />

    <el-dialog
      :visible.sync="delShow"
      width="480px"
      append-to-body
      class="del-dialog"
    >
      <div class="del-img"></div>
      <div class="del-msg">
        <div class="msg1">
          确认要删除<span>{{ delName }}</span
          >吗？
        </div>
        <div class="msg2">删除后数据不可恢复！请谨慎操作！</div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="cancel" @click="delShow = false">取 消</el-button>
        <el-button class="commit" @click="handleDelete" type="primary"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  getlistClearTables,
  delScckocMeta,
  getMainDbInfo,
  getPrimaryRs,
  getListOthers,
} from "@/api/scckocMeta/scckocMeta";
import {
  findTable,
  changeState,
  findTemplate,
  findTemplateCnull,
} from "@/api/burnPower/interface";
export default {
  name: "mainDataBase",
  data() {
    return {
      //中文名
      cardName: [
        "元数据",
        "化源网",
        "",
        "物种",
        "动力学",
        "实验高温热物性",
        "",
        "",
        "热力学",
        "层级火焰",
        "点火延迟",
        "输运",
        "其他",
      ],
      scckocMetaList: [],
      total: 7,
      // 遮罩层
      loading: false,
      // 导出遮罩层
      exportLoading: false,
      // 导入遮罩层
      uploadLoading: false,
      // 选中数组
      ids: [],
      delId: null,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 弹出层标题
      title: "",
      // 是否显示导入文件弹窗
      uploadVisibile: false,
      // 是否显示弹出层
      open: false,
      delShow: false,
      delName: "",
      PrimaryRs: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        tableName: null,
        schemaId: null,
        total: null,
        dataState: null,
        dataSource: null,
        dataType: "F",
        storeLoc: null,
        createrId: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      cardState: ["物种", "热力学", "动力学", "化源网", "元数据", "热物性"],
      //导入数据信息
      uploadFileData: { templateId: null, createId: null, dataSource: null },
    };
  },
  created() {
    this.getList();
    console.log("data", this.scckocMetaList);
    this.getPrimaryRss();
    console.log(this.PrimaryRs);
  },
  mounted() {},
  methods: {
    //中文名匹配
    getPrimaryRss() {
      getPrimaryRs().then((res) => {
        for (let i = 0; i < res.data.length; i++) {
          this.PrimaryRs.push(res.data[i]);
        }
      });
    },
    //静态，待调整
    getList() {
      this.loading = true;
      getListOthers(this.queryParams.pageNum, this.queryParams.pageSize).then(
        (response) => {
          console.log("response", response.rows);
          this.scckocMetaList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    handleDetail(item) {
      console.log("item ", item);
      switch (item.schemaId) {
        case 1:
          this.$router.push({
            path: "/output/mainDataBase/basicInfo",
            query: item,
          });

          break;
        case 3:
          this.$router.push({
            path: "/output/mainDataBase/density",
            query: item,
          });
          break;
        case 6:
          this.$router.push({
            path: "/output/mainDataBase/thermoInfo",
            query: item,
          });
          break;
        case -1:
          this.$router.push({
            path: "/output/mainDataBase/scckoc/Chemsrc",
            query: item,
          });
          break;
        case -2:
          this.$router.push({
            path: "/output/mainDataBase/scckoc/scckocMeta",
            query: item,
          });
          break;
        case 9:
          this.$router.push({
            path: "/output/mainDataBase/finally_new",
            query: item,
          });
          break;
        case 2:
          this.$router.push({
            path: "/output/mainDataBase/dynamic_info",
            query: item,
          });
          break;
        case 8:
          this.$router.push({
            path: "/output/mainDataBase/ignite",
            query: item,
          });
          break;
        case 7:
          this.$router.push({
            path: "/output/mainDataBase/laminar",
            query: item,
          });
          break;
      }
    },

    // //搜索按钮操作
    // handleQuery() {
    //   console.log("搜索");
    // },

    /** 搜索按钮操作 */
    handleQuery() {
      let table = this.queryParams.tableName;
      let createrId = this.queryParams.createrId;
      let state = this.queryParams.dataState;
      let page = this.queryParams.pageNum;

      let size = this.queryParams.pageSize;
      console.log("get :", this.queryParams);

      let type = "F";

      console.log("您已上传创建人信息");
      findTable(table, createrId, type, page, size, state).then((res) => {
        this.scckocMetaList = res.rows;
        console.log(res, "scckocMetaList1");
        console.log(res.data, "scckocMetaList1");
        // console.log(this.scckocMetaList, "name");
        this.pageTotal = parseInt(res.total);
        console.log("total", this.total);
        // this.loading = false;
        console.log("dataState1: ", this.queryParams.dataState);
      });
    },
    //删除
    gethandleDelete(item) {
      this.delShow = true;
      this.delName = item.tableAlias;
      this.delId = item.id;
      console.log("getid:", this.delId);
    },
    handleDelete() {
      delScckocMeta(this.delId)
        .then((res) => {
          this.getList();
          this.msgSuccess("删除成功");
          this.delId = null;
          this.ids = [];
        })
        .catch(() => {});
    },

    //重置按钮操作
    resetQuery() {
      this.form = {
        id: null,
        tableName: null,
        schemaId: null,
        dataState: null,
        dataSource: null,
        dataType: null,
        storeLoc: null,
        createTime: null,
        createrId: null,
      };
      this.queryParams = this.form;
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-form-item__label {
  // margin-left: 37px;
  font-size: 14px;
  font-weight: 400;
  color: #333333;
  line-height: 37px;
}
::v-deep.first-form {
  .el-form-item__label {
    margin-left: 0;
  }
}
::v-deep .el-input--small .el-input__inner {
  width: 160px;
  height: 32px;
  background: #ffffff;
  border-radius: 4px 4px 4px 4px;
  opacity: 1;
  border: 1px solid #eeeeee;
}
::v-deep .mb8 .el-button {
  font-size: 16px;
}
::v-deep .el-form .el-button {
  font-size: 16px;
}
.automatic {
  display: flex;
  margin-bottom: 20px;
  align-items: center;
  span {
    margin-right: 10px;
    width: 4vw;
  }
}
.autoAlert {
  position: absolute;
  top: 0px !important;
}
::v-deep .automatic .el-select {
  width: 80%;
}
// .pagination-container {
//   background: #F5F5F5;
//   max-width: 1152px;
//   // .el-pagination {
//   //   right: 1.3125rem;
//   //   position: absolute;
//   // }
// }
</style>

<style lang="scss" scoped>
.head {
  min-width: 1152px;
  height: 4.8125rem;
  background: #ffffff;
  margin: 0 1.5rem 0.6875rem 0;
  padding: 1.25rem 0.9375rem;
  border-radius: 0.5rem;
}
.caoz {
  padding-left: 5px;
  width: 271px;
  float: right;
}
::v-deep .el-form .el-button {
  font-size: 14px;

  font-weight: 400;
}
.search-btn {
  padding: 0 1.25rem;
  width: 128px;
  height: 2rem;
  color: #ffffff;
  background: #bd4541;
  border-radius: 0.25rem;
}
.reset-btn {
  padding: 0 1.25rem;
  height: 2rem;
  width: 128px;
  font-size: 0.875rem;
  border: 1px solid #eeeeee;
  border-radius: 0.25rem;
}
.card-list {
  position: relative;
  min-width: 1152px;
  margin: 0 1.5rem 0.6875rem 0;
  padding-top: 2.5rem;
  padding-left: 1rem;
  // height: 49.375rem;
  border-radius: 0.25rem;
  background: #ffffff;
}
.card-title {
  position: absolute;
  top: 1.1875rem;
  height: 1rem;
  font-size: 0.75rem;
  font-weight: 400;
  color: #999999;
  line-height: 0.875rem;
}
.pagination-container {
  background: #f5f5f5;
  min-width: 1152px;
}
.data-card {
  padding: 0.875rem 1.125rem 0 1rem;
  margin-bottom: 0.8125rem;
  position: relative;
  width: 16.875rem;
  height: 8.5rem;
  background: #ffffff;
  border-radius: 0.3125rem;
  opacity: 1;
  border: 0.0625rem solid #f5f5f5;
  .card-img {
    position: absolute;
    right: 1.125rem;
    top: 1.0625rem;
    width: 1.125rem;
    height: 1.125rem;
    background: url("./icon.png");
    background-size: cover;
  }
  .el-icon-date {
    width: 14px;
  }
  .dn-card {
    color: #999999;
    margin-top: 11px;
    margin-bottom: 11px;
    font-size: 15px;
    font-weight: 300;
    line-height: 0.9375rem;
  }

  .caozuo {
    a {
      margin: 0px 3px 0px 3px;
    }
  }
  .card-state {
    &1 {
      width: 64px;
      height: 24px;
      font-size: 15px;
      background: #f5fff6;
      border-radius: 33px;
      opacity: 1;
      text-align: center;
      font-weight: 600;
      color: #f59a23;
      line-height: 24px;
      margin-bottom: 10px;
    }
    &2 {
      width: 64px;
      height: 24px;
      font-size: 15px;
      background: #fff8f8;
      border-radius: 33px;
      opacity: 1;
      text-align: center;
      font-weight: 600;
      color: #f59a23;
      line-height: 24px;
      margin-bottom: 10px;
    }
    &3 {
      width: 64px;
      height: 1.5rem;
      font-size: 15px;
      background: #f5f8ff;
      border-radius: 2.0625rem;
      opacity: 1;
      text-align: center;
      font-weight: 600;
      font-size: 15px;
      color: #2b40ff;
      line-height: 1.5rem;
      margin-bottom: 10px;
    }
    &4 {
      width: 64px;
      height: 1.5rem;
      font-size: 15px;
      background: #f5fff6;
      border-radius: 2.0625rem;
      opacity: 1;
      text-align: center;
      font-weight: 600;
      font-size: 15px;
      color: #479706;
      line-height: 1.5rem;
      margin-bottom: 10px;
    }
    &5 {
      width: 64px;
      height: 24px;
      font-size: 15px;
      background: #fff9f5;
      border-radius: 33px;
      opacity: 1;
      text-align: center;
      font-weight: 600;
      font-size: 15px;
      color: #ff7c24;
      line-height: 1.5rem;
      margin-bottom: 10px;
    }
    &6 {
      width: 110px;
      height: 24px;
      font-size: 15px;
      background: #fff8f8;
      border-radius: 33px;

      opacity: 1;
      text-align: center;
      font-weight: 600;
      font-size: 15px;
      color: #dc322f;
      line-height: 1.5rem;
      margin-bottom: 10px;
    }
    &8 {
      width: 64px;
      height: 1.5rem;
      font-size: 15px;
      background: #fff5f7;
      border-radius: 2.0625rem;
      opacity: 1;
      text-align: center;
      font-weight: 600;
      font-size: 15px;
      color: #ff5084;
      line-height: 1.5rem;
      margin-bottom: 10px;
    }

    &9 {
      width: 64px;
      height: 24px;
      font-size: 15px;
      background: #f7f5ff;
      border-radius: 33px;
      opacity: 1;
      text-align: center;
      font-weight: 600;
      color: #8146ff;
      line-height: 24px;
      margin-bottom: 10px;
    }
    &10 {
      width: 64px;
      height: 24px;
      font-size: 15px;
      background: #fff8f8;
      border-radius: 33px;
      opacity: 1;
      text-align: center;
      font-weight: 600;
      color: #dc322f;
      line-height: 24px;
      margin-bottom: 10px;
    }
    &11 {
      width: 64px;
      height: 24px;
      font-size: 15px;
      background: #fff8f8;
      border-radius: 33px;
      opacity: 1;
      text-align: center;
      font-weight: 600;
      color: #dc322f;
      line-height: 24px;
      margin-bottom: 10px;
    }
    &12 {
      width: 64px;
      height: 24px;
      font-size: 15px;
      background: #fff8f8;
      border-radius: 33px;
      opacity: 1;
      text-align: center;
      font-weight: 600;
      color: #bfbf00;
      line-height: 24px;
      margin-bottom: 10px;
    }
    &13 {
      width: 64px;
      height: 24px;
      font-size: 15px;
      background: #fff8f8;
      border-radius: 33px;
      opacity: 1;
      text-align: center;
      font-weight: 600;
      color: #7b4d12;
      line-height: 24px;
      margin-bottom: 10px;
    }
  }
  .cancel {
    border: 0;
    height: 31px;
    font-size: 16px;
    padding: 0 10px;
    font-weight: 400;
    color: #666666;
  }
  .commit {
    width: 128px;
    height: 31px;
    font-size: 14px;
    padding: 0;
    font-weight: 400;
    color: #ffffff;
    // line-height: 31px;
    background: #bd4541;
    border-radius: 4px;
    border: 0;
  }
  ::v-deep .el-dialog {
    border-radius: 10px;
    // height: 288px;
    // top: 158px;
    &__body {
      padding-bottom: 0;
      padding-top: 0;
      padding: 10px 38px 10px 38px;
    }
    &__header {
      padding: 10px 38px 10px 38px;
      .el-dialog__title {
        font-size: 18px;
        font-weight: 600;
        color: #333333;
      }
    }
    &__footer {
      padding: 10px 38px 20px 38px;
    }
    .el-input__inner {
      width: 248px;
      height: 31px;
      border-radius: 5px;
      margin-left: 15px;
      font-size: 14px;

      font-weight: 400;
    }
    .el-form-item__label {
      margin: 0;
    }
    .el-radio-button {
      margin-left: 15px;
      &__inner {
        width: 124px;
        height: 31px;
        // background: #BD4541;
        border-radius: 4px 4px 4px 4px;
      }
    }
    .el-radio-button__orig-radio:checked + .el-radio-button__inner {
      background-color: #bd4541;
      border-color: #bd4541;
    }
  }

  .form-table {
    padding: 0;
    width: 409px;
    height: 201px;
    margin-left: 15px;
    border-radius: 6px;
    opacity: 1;
    border: 1px solid #eeeeee;
    // overflow:auto;
    ::v-deep .el-table td,
    .el-table th {
      padding: 6px 0;
    }
  }

  .del-dialog {
    ::v-deep .el-dialog {
      height: 270px;
    }
    .del-img {
      width: 56px;
      height: 56px;
      margin: 0 auto;
      background: url("../../../assets/images/warnning.png");
      background-size: cover;
    }
    .del-msg {
      margin-top: 14px;
      text-align: center;
      .msg1 {
        font-size: 16px;
        font-weight: 600;
        color: #333333;
        span {
          color: #bd4541;
        }
      }
      .msg2 {
        margin-top: 8px;
        font-size: 13px;
        font-weight: 400;
        color: #bd4541;
      }
    }
    .dialog-footer {
      margin-top: 37px;
    }
  }
}
</style>
